﻿using QFramework;
using UnityEngine;

namespace ProjectMyFarmAndShe
{
    public class SubToolbarCountCommand : AbstractCommand
    {
        private readonly string mToolbarKey;
        private readonly int mCount;

        public SubToolbarCountCommand(string key, int count)
        {
            mToolbarKey = key;
            mCount = count;
        }

        protected override void OnExecute()
        {
            var system = this.GetSystem<IToolbarSystem>();
            system.SubToolbarData(mToolbarKey, mCount);
            
            SubPlantCount(mToolbarKey,mCount);
        }

        void SubPlantCount(string key, int count)
        {
            if (key == "Potato")
            {
                Global.PotatoCount.Value -= count;
            }
            else if (key == "Grape")
            {
                Global.GrapeCount.Value -= count;
            }
            else if (key == "PinkRadish")
            {
                Global.PinkRadishCount.Value -= count;
            }
            else if (key == "Turnip")
            {
                Global.TurnipCount.Value -= count;
            }
        }
    }
}